/*
 *
 * Copyright 2018-2020,2022,2024 NXP.
 *
 * NXP Confidential. This software is owned or controlled by NXP and may only be
 * used strictly in accordance with the applicable license terms. By expressly
 * accepting such terms or by downloading,installing, activating and/or otherwise
 * using the software, you are agreeing that you have read,and that you agree to
 * comply with and are bound by, such license terms. If you do not agree to be
 * bound by the applicable license terms, then you may not retain, install, activate
 * or otherwise use the software.
 *
 */

#ifndef UWBAPI_PROPRIETARY_INTERNAL_SRXXX_H
#define UWBAPI_PROPRIETARY_INTERNAL_SRXXX_H

#ifdef __cplusplus
extern "C" {
#endif

#include "phUwbTypes.h"
#include "UwbApi_Types.h"
#include "UwbApi_Internal.h"
#include <UwbApi_Types_Proprietary.h>

#if UWBFTR_SE_SN110
#include "UwbSeApi.h"

/**
 **
 ** Function         reset_se_on_error
 **
 ** Description      This function is called to cold reset the SE.
 **
 ** Returns          void
 **
 */
EXTERNC void reset_se_on_error(void);
#endif // UWBFTR_SE_SN110

/**
 **
 ** Function         processProprietaryNtf
 **
 ** Description      Process UCI NTFs in the proprietary group
 **
 ** Returns          associated event id
 **
 */
eResponse_Ext_Ntf_Event processProprietaryNtf(uint8_t oid, uint16_t responsePayloadLen, uint8_t *responsePayloadPtr);

/**
 **
 ** Function         processVendorNtf
 **
 ** Description      Process UCI NTFs in the vendor group
 **
 ** Returns          associated event id
 **
 */
eResponse_Ext_Ntf_Event processVendorNtf(uint8_t oid, uint16_t responsePayloadLen, uint8_t *responsePayloadPtr);

/**
 **
 ** Function         processProprietarySeNtf
 **
 ** Description      Process UCI NTFs in the proprietary SE group
 **
 ** Returns          associated event id
 **
 */
eResponse_Ext_Ntf_Event processProprietarySeNtf(uint8_t oid, uint16_t responsePayloadLen, uint8_t *responsePayloadPtr);

/**
 **
 ** Function         processInternalNtf
 **
 ** Description      Process UCI NTFs in the Internal group
 **
 ** Returns          void
 **
 */
eResponse_Ext_Ntf_Event processInternalNtf(uint8_t oid, uint16_t responsePayloadLen, uint8_t *responsePayloadPtr);
/**
 **
 ** Function:        extDeviceManagementCallback
 **
 ** Description      Process UCI NTFs in the proprietary group
 **
 ** Returns          void
 **
 */
EXTERNC void extDeviceManagementCallback(uint8_t gid, uint8_t oid, uint16_t paramLength, uint8_t *pResponseBuffer);
/**
 **
 ** Function:        getVendorAppConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for extended application related configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getVendorAppConfigTLVBuffer(
    uint8_t paramId, void *paramValue, uint16_t paramValueLen, uint8_t *tlvBuffer);

/**
 **
 ** Function:        getVendorDebugConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for Extended Debug Configs only.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getVendorDebugConfigTLVBuffer(
    uint16_t paramId, void *paramValue, uint16_t paramValueLen, uint8_t *tlvBuffer);

/**
 **
 ** Function:        getExtTestConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for extended test related configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getExtDeviceConfigTLVBuffer(uint8_t paramId, void *paramValue, uint8_t *tlvBuffer);

/**
 **
 ** Function:        getExtTestConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for extended test related configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getExtTestConfigTLVBuffer(uint16_t paramId, void *paramValue, uint8_t *tlvBuffer);

/**
 **
 ** Function:        parseDebugParams
 **
 ** Description:     Extracts Debug Params from the given byte array and updates
 *the structure
 **
 ** Returns:         None
 **
 */
EXTERNC void parseDebugParams(uint8_t *rspPtr, uint8_t noOfParams, UWB_DebugParams_List_t *DebugParams_List);

/**
 **
 ** Function:        DebugConfig_TlvParser
 **
 ** Description:     Debug configuration Tlv parser
 **
 ** Returns:         status
 **
 */
EXTERNC tUWBAPI_STATUS DebugConfig_TlvParser(
    const UWB_DebugParams_List_t *pDebugParams_List, UWB_Debug_Params_value_t *pOutput_param_value);

/**
 **
 ** Function:        parseDeviceInfo
 **
 ** Description:     Parse Manufacturer Specific Device Information from the
 **                  Given buffer as per UCI
 **                  pdevInfo:  Pointer to structure of device information data
 **
 ** Returns:         boolean, parse success or failure
 **
 */
EXTERNC BOOLEAN parseDeviceInfo(phUwbDevInfo_t *pdevInfo);

/**
 ** Function:        getExtCoreDeviceConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for Ext Core Device configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getExtCoreDeviceConfigTLVBuffer(
    uint16_t paramId, uint8_t paramLen, void *paramValue, uint8_t *tlvBuffer);

/**
 **
 ** Function:        parseExtGetDeviceConfigResponse
 **
 ** Description:     Convert received UCI response to deviceConfig object
 **
 ** Returns:         None
 **
 */
EXTERNC void parseExtGetDeviceConfigResponse(uint8_t *tlvBuffer, phDeviceConfigData_t *devConfig);

/**
 **
 ** Function:        setDefaultCoreConfigs
 **
 ** Description:     Sets all core configs. Default values are picked from
 **                  config file(phNxpUciHal_RhodesConfig.h)
 **
 ** Returns:         Status
 **
 */
EXTERNC tUWBAPI_STATUS setDefaultCoreConfigs(void);

/**
 *  Function         setVendorConfigs
 *
 * Description      This function is called during init process to
 *                  apply vendor configs from the config file
 *
 * Returns          status , success or failure
 *
 */
EXTERNC tUWBAPI_STATUS setVendorConfigs(void);

/**
 *
 * Function:        parseExtGetCalibResponse
 *
 * Description:     Convert received UCI response to phCalibRespStatus_t object
 *
 * Returns:         None
 *
 */
EXTERNC void parseExtGetCalibResponse(uint8_t *tlvBuffer, phCalibRespStatus_t *calibResp);

/**
 * Function     :    recoverUWBS
 *
 * Description  :    function to recover from crash, cmd timeout.
 *
 * Returns      :    status
 *
 *
 */
EXTERNC tUWBAPI_STATUS recoverUWBS();

/**
 **
 ** Function:        getTestConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for test configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getTestConfigTLVBuffer(uint8_t paramId, uint8_t paramLen, void *paramValue, uint8_t *tlvBuffer);
EXTERNC tUWBAPI_STATUS VendorAppConfig_TlvParser(
    const UWB_VendorAppParams_List_t *pAppParams_List, UWB_AppParams_value_au8_t *pOutput_param_value);
#if UWBFTR_Radar

/**
 **
 ** Function:        getExtRadarAppConfigTLVBuffer
 **
 ** Description:     Convert one TLV Application Configuration Structure to Byte
 **                  Array for extended radar application related configs.
 **
 ** Returns:         Length of the data
 **
 */
EXTERNC uint8_t getExtRadarAppConfigTLVBuffer(
    uint16_t paramId, void *paramValue, uint16_t paramValueLen, uint8_t *tlvBuffer);
#endif // UWBFTR_Radar//

#if UWBFTR_CSA

/**
 **
 ** Function:        parseCapabilityCCCParams
 **
 ** Description:     Parse Capability CCC Params Information from the given buffer as per UCI
 **                  pDevCap:  Pointer to structure of device capability data
 **
 ** Returns:         boolean, failure when the length of the received param is incorrect,
 **                  success if the parsing is successful or an unknown Param is received.
 **
 */
EXTERNC BOOLEAN parseCapabilityCCCParams(
    phUwbCapInfo_t *pDevCap, uint8_t paramId, uint16_t *index, uint8_t length, uint8_t *capsInfoData);
#endif // UWBFTR_CSA

#ifdef __cplusplus
} // closing brace for extern "C"
#endif

#endif // UWBAPI_PROPRIETARY_INTERNAL_SRXXX_H
